/**
 * Created by 小敏哥on 2017/3/16.
 */

import apiHelper from './apiHelper';

class HomeService {

    //检查是否有未完成订单
    checkIfOrderPay(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}order/findByUserId`,
            data: {
                method: 'get',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //获取车辆列表
    getCarList(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}cars/list`,
            data: {
                method: 'get',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //添加车辆
    addCar(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}cars/save`,
            data: {
                method: 'post',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }


    //检测车辆能否年检
    checkInspection(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}inspection/validate`,
            data: {
                method: 'post',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //查询清单详情链接接口
    getViewUri(data){
        let requestParam = {
            url: `${apiHelper.baseApiUrl}order/viewUri`,
            data: {
                method: 'get',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //获取微信配置
    getWeixinConfig(data) {
        let wxApiUrl = window.location.href.indexOf('https://annualcheck.cx580.com/') > -1 ? "https://webservice.cx580.com/" : "http://test-webserver.cx580.com:9071/";
        let requestParam = {
            url: `${wxApiUrl}share/url`,
            data: {
                method: 'post',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //根据经纬度获取城市名
    getCityName(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}inspection/getCityName`,
            data: {
                method: 'post',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //获取滚动提示文字
    getSliderTips(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}inspection/getTips`,
            data: {
                method: 'get',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }

    //获取首页广告
    getAd(data) {
        let requestParam = {
            url: `${apiHelper.baseApiUrl}advert/getAd`,
            data: {
                method: 'get',
                body: data
            }
        };
        return apiHelper.fetch(requestParam);
    }
}

export default new HomeService();